﻿<section class="Hui-article-box">
	<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
		<span class="c-gray en">&gt;</span>
		公众号管理
		<span class="c-gray en">&gt;</span>
		公众号素材
		<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
	</nav>
	<div class="Hui-article">
		<article class="cl pd-20">
			<div class="cl pd-5 bg-1 bk-gray mt-20">
				<span class="l"> 
					<a href="javascript:;" onclick="add_material('添加素材','{:url('admin/Weixinload/addMaterial')}','700','500')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加素材</a>

					<a href="javascript:;" onclick="add_article('添加图文素材','{:url('admin/Weixinload/addArticle')}','1200','800')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加图文素材</a>
				</span>
				<span class="r">
					<a href="{:url('Weixinload/material_list',['type'=>'image'])}" class="btn btn-primary radius"> 图片素材</a>
					<a href="{:url('Weixinload/material_list',['type'=>'video'])}" class="btn btn-primary radius">视频素材</a>
					<a href="{:url('Weixinload/material_list',['type'=>'voice'])}" class="btn btn-primary radius">语言素材</a>
					<a href="{:url('Weixinload/material_list',['type'=>'news'])}" class="btn btn-primary radius">图文素材</a> 
				</span>
			</div>
			<div class="mt-10">
				<table class="table table-border table-bordered table-bg table-hover table-sort">
					<thead>
						<tr class="text-c">
							<th width="80">素材ID</th>
							<th width="100">素材名称</th>
							<th width="100">更新时间</th>
							<th width="120">地址</th>
							<th width="50">操作</th>
						</tr>
					</thead>
					<tbody>
						{volist name="material_list" id="va"}
						{if condition="$type !== 'news'"}
						<tr class="text-c">
							<td>{$va.media_id}</td>
							<td>{$va.name}</td>
							<td>{$va.update_time}</td>
							<td>{$va.url}</td>
							<td class="td-manage">
								<a title="删除" href="javascript:;" onclick="material_del(this,{$va.media_id})" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
							</td>
						</tr>
						{else/}
						<tr class="text-c">
							<td>{$va.media_id}</td>
							<td>无</td>
							<td>{$va.update_time}</td>
							<td>无</td>
							<td class="td-manage">
								<a title="删除" href="javascript:;" onclick="material_del(this,{$va.media_id})" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
							</td>
						</tr>
						{/if}
						{/volist}
					</tbody>
				</table>
			</div>
		</article>
	</div>
</section>
</body>
<script type="text/javascript">
/*素材-增加*/
function add_material(title,url,w,h){
	layer_show(title,url,w,h);
}

// 图文素材添加
function add_article(title,url,w,h){
	layer_show(title,url,w,h);
}

/*素材-删除*/
function material_del(obj,media_id){
	layer.confirm('确认要删除该素材吗？',function(index){
		//此处请求后台程序，下方是成功后的前台处理……
		$.ajax({
			type:"post",
			url:"{:url('admin/Weixinload/delMaterial')}",
			data:{'media_id':media_id},
			success:function(res){
				var _json = JSON.parse(res);
				if(_json.status == 1){
					$(obj).parents("tr").remove();
					layer.msg(_json.msg,{icon:1,time:1000});
				}else{
					layer.msg(_json.msg);
				}
			}
		});
		
	});
}
</script>
</html>